<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /* 
            1,1,2,3,5,8,13,21,34,55......

            1,2,3,4,5,6,7,8,9,10
        */
        function fn(n) {
            //前面两个没有规律,返回的结果都是1
            if(n == 1 || n == 2){ //临界值
                return 1;
            }
            return fn(n-2) + fn(n -1) 
            /* 
                比如2:
                fn(7)
                    fn(6)                                                                       +fn(5)
                      (4)                    +fn(3)                 fn(3)+fn(2)                 fn(3)+fn(2)         fn(2)+fn(1)
                                f  fn(5)                                            +fn(4)                     fn(4)               +fn(3) 
                            fnn(3)   +fn(2)          fn(2)+fn(1)             fn(2)+fn(1)              fn(2)+fn(1)            2
                                    fn(2)+fn(1)  3   + 2                    3                               3

                比如:
                fn(5)
                    fn(4)                               +fn(3)
                        fn(3)+fn(2)                         fn(2)+fn(1)
                            fn(2)+fn(1)+fn(2)                   1+1
                            3                +                   2
                            5
            
            */
        }
        var result = fn(7)
        console.log(result);
    </script>
</body>

</html>